package com.wind.cqboot.plugin;

import org.springframework.stereotype.Component;

import net.lz1998.cq.event.message.CQGroupMessageEvent;
import net.lz1998.cq.robot.CQPlugin;
import net.lz1998.cq.robot.CoolQ;

@Component
public class AdPlugin extends CQPlugin
{
    @Override
    public int onGroupMessage(CoolQ cq, CQGroupMessageEvent event)
    {
        String msg = event.getMessage();
        Long groupId = event.getGroupId();
        Long userId = event.getUserId();
        if (msg.contains("阿里云")&&msg.contains("https://www.aliyun.com/"))
        {
            String content = " 被检测到广告,已被永久踢出群聊,如果误踢，请管理员加回";
            String result = userId + content;
            cq.sendGroupMsg(groupId, result, false);
            cq.setGroupKick(groupId, userId, true);
            return MESSAGE_BLOCK;
        }
        // 继续执行下一个插件
        return MESSAGE_IGNORE;
    }
}
